let user=JSON.parse(localStorage.getItem("user")||"{}") 
let store={
  state:{
    user:user
  },
  mutations:{
    setUser(state,user){
      state.user=user
    }
  },
  actions:{
    //登录方法
    setUser({commit},user){
      commit("setUser",user)
      localStorage.setItem("user",JSON.stringify(user))
      localStorage.setItem("token",JSON.stringify(user.token))
    }
  }

}
export default store